<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/pages/common/header.jsp"%>
<jdf:themeFile file="jquery.jqGrid.css"/>
<jdf:themeFile file="jqGrid/i18n/grid.locale-cn.js" />
<jdf:themeFile file="jqGrid/jquery.jqGrid.src.js" />
<jdf:themeFile file="fileuploader.css" />
<jdf:themeFile file="fileuploader.js" />
<jdf:themeFile file="business/quotation${template}.js" />
</head>
<body>
	<div class="contentBody contentborder">
		<div class="tab-pane" id="tabPane">
			<div id="message">${message}</div>
			<div class="tab-page" id="tabPage1">
				<h1 class="tab">报价单</h1>
				<div class="contentborder tableForm">
					<jdf:form bean="entity" scope="request">
						<form action="${dynamicDomain}/quotation/save?action=${param.action}" method="post" id="Order">
							<input type="hidden" name="id">
							<input type="hidden" name="objectId">
							<input type="hidden" name="salesId">
							<input type="hidden" name="status" id="status">
							<input type="hidden" name="generateDate">
							<input type="hidden" name="appovalUserId">
							
							<table class="inputTable">
							     <c:if test="${not empty entity.id }">
                                 <tr>
                                    <td class="label cancelBorderLeft" width="20%">
                                        <label for="orderNo">编号：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        ${entity.quotationNo}
                                    </td>
                                </tr>
                                </c:if>
                                <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="customerId">客户：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="hidden" name="customerId" id="customerId" validate="true">
                                        <c:choose>
                                           <c:when test="${not empty entity.id}">
                                               ${entity.customer.name}
                                           </c:when>
                                           <c:otherwise>
                                           <input type="text" id="customerName" value="${entity.customer.name}" size="70" readonly="readonly"/>
                                           <a href="${dynamicDomain}/customer/select?ajax=1" class="colorbox">选择客户</a>
                                           </c:otherwise>
                                        </c:choose>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="companyId">所属公司：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="hidden" name="companyId" id="companyId" validate="true">
                                        <input type="text" id="companyName" value="${entity.company.name}" size="70" readonly="readonly"/>
                                        <c:if test="${view!=1}">
                                        <a href="${dynamicDomain}/company/select?ajax=1" class="colorbox">选择公司</a>
                                        </c:if>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="title">标题：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="title" size="70">
                                    </td>
                                 </tr>
								<tr>
								    <td class="label cancelBorderLeft">
                                        <label for="specification">Size：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <textarea rows="4" cols="80" name="specification"></textarea>
                                    </td>
                                 </tr>
                                 <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="packing">Packing：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <textarea rows="4" cols="80" name="packing"></textarea>
                                    </td>
                                 </tr>
                                 <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="origination">Origination：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <textarea rows="4" cols="80" name="origination"></textarea>
                                    </td>
                                 </tr>
                                 <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="note">Note：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <textarea rows="3" cols="80" name="note"></textarea>
                                    </td>
                                 </tr>
                                 <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="payment">Payment：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="payment" size="70">
                                    </td>
                                 </tr>
                                 <tr>
                                    <td class="label cancelBorderLeft">
										<label for="expiredDate">有效期：</label>
									</td>
									<td class="content">
										<input type="text" name="expiredDate" id="expiredDate" size="12" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
									</td>
                                    <td class="label">
                                        <label for="currency">币种：</label>
                                    </td>
                                    <td class="content">
                                        <select name="currency">
                                            <option value=""></option>
                                            <jdf:select dictionaryId="1006"/>
                                        </select>
                                    </td>
								</tr>
								<c:if test="${quotationTemplate=='quotation2'}">
								<tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="deliveryDate">交货时间：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="deliveryDate" id="deliveryDate" size="12" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
                                    </td>
                                </tr>
                                </c:if>
							</table>
						</form>
					</jdf:form>
					<div style="margin: 1px;">
						<table id="orderItemsTable"></table>
						<div id="pager"></div>
						<table id="orderChargeTable1"></table>
                        <div id="pager1"></div>
                        <table id="orderChargeTable2"></table>
                        <div id="pager2"></div>
					</div>
					<div class="right" style="margin: 2px;width: 100%;">
                       <div id="filelimit-fine-uploader">
                       </div>
                       <c:forEach varStatus="num" var="item" items="${entity.pictures}">
                           <div id="d_f_${item.fileId}" style="float: left;width: 180px;">
                               <div style="vertical-align: baseline;">
                                   <textarea id="fileRemark_${item.fileId}">${item.remark}</textarea>
                                   <button type="button" onclick="saveRemark('${item.fileId}')">保存备注</button>
                                   <button type="button" onclick="deletePicture('${item.fileId}')">删除</button>
                               </div>
                            
                               <div style="vertical-align: top;">
	                               <a href="${dynamicDomain}/download/${item.fileId}${item.fileSuffix}" class="picture" title="${item.fileName}">
	                                   <img alt="${item.fileName}" src="${dynamicDomain}/download/${item.fileId}${item.fileSuffix}" width="140">
	                               </a>
                               </div>
                           </div>
                       </c:forEach>
                    </div>
					<div class="right" style="margin: 2px;">
						<c:if test="${view!=1 && (empty entity.status || entity.status == 1)}">
                            <button type="button" onclick="$('#status').val(1);$('#Order').submit();" class="submit_button">保存草稿</button>
                        </c:if>
                        <c:if test="${(view!=1 && (entity.status <20))||param.action=='page'}">
                            <button type="button" onclick="$('#status').val(10);$('#Order').submit();" class="submit_button">提交</button>
                        </c:if>
						<c:if test="${not empty message}">
						<button type="button" onclick="toUrl('${dynamicDomain}/quotation/create?action=${param.action}')">继续增加</button>
						</c:if>
						<c:choose>
							<c:when test="${param.action=='page'}">
								<button type="button" onclick="toUrl('${dynamicDomain}/quotation/back')">返回</button>
							</c:when>
							<c:otherwise>
								<button type="button" onclick="toUrl('${dynamicDomain}/quotation/${param.action}')">返回</button>
							</c:otherwise>
						</c:choose>
					</div>
				</div>
			</div>
		</div>
	</div>
	<jdf:tableLabelValidate domain="Quotation"/>
	<script type="text/javascript">
	var bankStatementId = "${entity.objectId}";
	 var units = "";
     <c:forEach varStatus="num" var="item" items="${units}">
     units+="${item.value}:${item.name};";
     </c:forEach>
     units=units.substring(0,units.length-1);
     
     orderfileCount = ${fn:length(entity.pictures)};
     window.onload = createUploader; 
     
     function saveRemark(fileId){
    	   var remark = $("#fileRemark_" + fileId);
    	   if(remark.val()!=""){
    		   $.ajax({
    	             url: appRoot + "/picture/update/" + fileId + "?ajax=1",
    	             type:'post',
    	             dataType:'json',
    	             data:"remark=" + encodeURIComponent(remark.val()),
    	             success:function(msg){
    	                 if(msg.success){
    	                     alert("保存成功");
    	                 }
    	             }
    	       });
    	  }
     }
	</script>
	
</body>
</html>